<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="java.util.Map"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.model.Payment"%>
<stripes:form name="queryDetailForm" 
	id="queryDetailForm" beanclass="com.feib.soeasy.action.Soez5006ActionBean"	method="post" onsubmit="javascript: return false;">	
<c:choose>
	<c:when test="${null != actionBean.resultChannelCommissions && not empty actionBean.resultChannelCommissions}">
	
	
	<div>
		<table id="listTable">
			<thead>						
				<tr>
					<th>超商</th> 	
					<th>CODE</th>
					<th>業者代號</th>
					<th>業者名稱</th>
					<th>繳費帳號</th>
					<th>客戶名稱</th>	
					<th>客戶編號</th>				
					<th>繳費日期</th>
					<th>銷帳日期</th>
					<th>代收金額</th>	    
		</tr>
			</thead>
			<tbody>
				<c:forEach items="${actionBean.resultChannelCommissions}" var="viewObj" varStatus="rowstat">
				
				<tr>
					<td>
						<%
						Payment payment = (Payment)pageContext.getAttribute("viewObj");
						if (null != payment.getWriteOffPayment())
							out.println(CodeTableUtil.getInstance().getCodeName(CodeTableUtil.CODE_KIND_CHANNEL, payment.getWriteOffPayment().getChannel()));
						%>						
					</td>
					<td><c:out value="${fn:substring(viewObj.barcodeStores1,6,9)}"/></td>
					<td><c:out value="${viewObj.group.groupNo}"/></td>
					<td><c:out value="${viewObj.group.groupName}"/></td>
					<td><c:out value="${viewObj.virtualAccount}"/></td>
					<td><c:out value="${viewObj.payerName}"/></td>
					<td><c:out value="${viewObj.payerId}"/></td>
					<td align="center"><fmt:formatDate value="${viewObj.writeOffPayment.txDate}" pattern="yyyy/MM/dd"  /></td>
					<td align="center"><fmt:formatDate value="${viewObj.writeOffPayment.writeOffDate}" pattern="yyyy/MM/dd"  /></td>
					<td align="right"><fmt:formatNumber value="${viewObj.writeOffPayment.amount}" pattern="##,###" /></td>
				</tr>
				</c:forEach>
			</tbody>
		</table>
		</div>
		<stripes:hidden id="hidden5.queryChannel" name="queryChannel"/>
		<stripes:hidden id="hidden5.queryCommissionCode" name="queryCommissionCode"/>	
		<stripes:hidden id="hidden5.qryDateFrom" name="qryDateFrom"/>
		<stripes:hidden id="hidden5.qryDateTo" name="qryDateTo"/>
				
		<div id="paginationBar">
			<input type="button" id="doDownloadDetailExcelFileBtn" name="doDownloadExcelFileBtn"  value="下載(Excel)"/>
			<input type="button" id="printBtn2" value="列印" onclick="javascript:divPrint('queryCommissionCodeResultDiv');"/>
		</div>
		
		
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'<%=UserUtil.getCurrentMenuItemName() %>' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  
			});

			$("[id^='doDownloadDetailExcelFileBtn']").click(function() {
				var queryChannel = $('#hidden5\\.queryChannel').val();
				var queryCommissionCode = $('#hidden5\\.queryCommissionCode').val();
				var qryDateFrom = $('#hidden5\\.qryDateFrom').val();
				var qryDateTo = $('#hidden5\\.qryDateTo').val();

				doDownloadDetailExcelFileBtn(queryChannel,queryCommissionCode,qryDateFrom,qryDateTo  );
			});
			
		});
		//-->
		</script>	
	</c:when>
	<c:otherwise>
	
	
	<div id="queryNothingBlockDiv" style="display: none;">
			查無資料
		</div>		
	<table id="listTable">
			<thead>						
				<tr>
					<th>超商</th> 	
					<th>CODE</th>
					<th>業者代號</th>
					<th>業者名稱</th>
					<th>繳費帳號</th>
					<th>客戶名稱</th>	
					<th>客戶編號</th>				
					<th>繳費日期</th>
					<th>銷帳日期</th>
					<th>代收金額</th>	    
		</tr>
			</thead>
		</table>	
		
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'<%=UserUtil.getCurrentMenuItemName() %>' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  
			});

			$("[id^='doDownloadDetailExcelFileBtn']").click(function() {
				var queryChannel = $('#hidden5\\.queryChannel').val();
				var queryCommissionCode = $('#hidden5\\.queryCommissionCode').val();
				var qryDateFrom = $('#hidden5\\.qryDateFrom').val();
				var qryDateTo = $('#hidden5\\.qryDateTo').val();
				alert(qryDateFrom);
				//doDownloadGroupExcelFile();
			});
			
		});
		//-->
		</script>			
	</c:otherwise>
</c:choose>
</stripes:form>